
Imports System
Imports System.Data.SqlClient


Namespace _2bMatesSite.BO
	''' <summary>
	''' A single comment about a user.
	''' </summary>
	Public Class UserComment
		Protected commentID As Integer
		Protected userID As Integer
		Protected fromUserID As Integer
		Protected comment As String
		Protected status As Status
		Protected [date] As DateTime

		Public Enum Status
			ucsNew = 0
			' new unaccepted - used when the user has switched on approval of comments
			ucsAccepted = 1
			' accepted comment - used when the user has switched on approval and approved his comment
			' - used when the user has switched off  approval of comments and has loaded the page with comments
			ucsNewAccepted = 2
			' new accepted comment - used when the user has switched off approval of comments
		End Enum

		Public Sub New(ByVal userID As Integer, ByVal fromUserID As Integer, ByVal comment As String)
			commentID = -1
			Me.userID = userID
			Me.fromUserID = fromUserID
			Me.comment = comment
			status = Status.ucsNew
			[date] = DateTime.Now
		End Sub

		Public Sub New(ByVal dr As SqlDataReader)
			commentID = dr.GetInt32(dr.GetOrdinal("ID"))
			comment = dr.GetString(dr.GetOrdinal("Comment"))
			userID = dr.GetInt32(dr.GetOrdinal("AboutUID"))
			fromUserID = dr.GetInt32(dr.GetOrdinal("PostedByUID"))
			status = DirectCast(dr.GetInt32(dr.GetOrdinal("Status")), Status)
			[date] = dr.GetDateTime(dr.GetOrdinal("Date"))
		End Sub

		Public ReadOnly Property ID() As Integer
			Get
				Return commentID
			End Get
		End Property

		Public ReadOnly Property AboutUserID() As Integer
			Get
				Return userID
			End Get
		End Property

		Public ReadOnly Property PostedByUserID() As Integer
			Get
				Return fromUserID
			End Get
		End Property

		Public ReadOnly Property Comment() As String
			Get
				Return comment
			End Get
		End Property

		Public Property CommentStatus() As Status
			Get
				Return status
			End Get
			Set
				status = value
			End Set
		End Property

		Public ReadOnly Property [Date]() As DateTime
			Get
				Return [date]
			End Get
		End Property
	End Class
End Namespace






